package com.platform.api;

import com.platform.annotation.SysLog;
import com.platform.controller.AbstractController;
import com.platform.entity.DeptVo;
import com.platform.service.ApiDeptService;
import com.platform.util.ApiBaseAction;
import com.platform.utils.Constant;
import com.platform.utils.R;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 部门管理Controller
 *
 * @author liepngjun
 * @email 939961241@qq.com
 * @date 2017-09-17 23:58:47
 */
@Api(tags = "部门管理")
@RestController
@RequestMapping("/api/dept")
public class ApiDeptController extends ApiBaseAction {
    @Autowired
    private ApiDeptService apiDeptService;

    /**
     * 部门列表
     *
     * @return R
     */
    @RequestMapping("/list")
    public Object list() {
        Map<String, Object> map = new HashMap<>();
        //如果不是超级管理员，则只能查询本部门及子部门数据
//        if (getUserId() != Constant.SUPER_ADMIN) {
//            map.put("deptFilter", apiDeptService.getSubDeptIdList(getDeptId()));
//        }
        List<DeptVo> deptList = apiDeptService.queryList(map);
        Map<String, Object> resultObj = new HashMap();
        resultObj.put("deptList", deptList);
        return toResponsSuccess(resultObj);
    }

}
